home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / CodeWarrior Lite / Metrowerks C⁄C++ Lite / Headers / Universal Headers 2.0.1f / FileTransfers.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-22  |  15.5 KB  |  371 lines  |  [TEXT/MMCC]

  1. /*
  2.      File:        FileTransfers.h
  3.  
  4.      Contains:    CommToolbox File Transfer Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __FILETRANSFERS__
  21. #define __FILETRANSFERS__
  22.  
  23.  
  24. #ifndef __WINDOWS__
  25. #include <Windows.h>
  26. #endif
  27. /*    #include <Types.h>                                            */
  28. /*        #include <ConditionalMacros.h>                            */
  29. /*    #include <Memory.h>                                            */
  30. /*        #include <MixedMode.h>                                    */
  31. /*    #include <Quickdraw.h>                                        */
  32. /*        #include <QuickdrawText.h>                                */
  33. /*    #include <Events.h>                                            */
  34. /*        #include <OSUtils.h>                                    */
  35. /*    #include <Controls.h>                                        */
  36. /*        #include <Menus.h>                                        */
  37.  
  38. #ifndef __CTBUTILITIES__
  39. #include <CTBUtilities.h>
  40. #endif
  41. /*    #include <Dialogs.h>                                        */
  42. /*        #include <Errors.h>                                        */
  43. /*        #include <TextEdit.h>                                    */
  44. /*    #include <StandardFile.h>                                    */
  45. /*        #include <Files.h>                                        */
  46. /*    #include <AppleTalk.h>                                        */
  47.  
  48. #ifndef __CONNECTIONS__
  49. #include <Connections.h>
  50. #endif
  51.  
  52. #ifndef __FILES__
  53. #include <Files.h>
  54. #endif
  55.  
  56. #ifndef __TERMINALS__
  57. #include <Terminals.h>
  58. #endif
  59.  
  60. #ifdef __cplusplus
  61. extern "C" {
  62. #endif
  63.  
  64. #if PRAGMA_ALIGN_SUPPORTED
  65. #pragma options align=mac68k
  66. #endif
  67.  
  68. #if PRAGMA_IMPORT_SUPPORTED
  69. #pragma import on
  70. #endif
  71.  
  72.  
  73. enum {
  74. /* current file transfer manager version    */
  75.     curFTVersion                = 2,
  76. /* FTErr    */
  77.     ftGenericError                = -1,
  78.     ftNoErr                        = 0,
  79.     ftRejected                    = 1,
  80.     ftFailed                    = 2,
  81.     ftTimeOut                    = 3,
  82.     ftTooManyRetry                = 4,
  83.     ftNotEnoughDSpace            = 5,
  84.     ftRemoteCancel                = 6,
  85.     ftWrongFormat                = 7,
  86.     ftNoTools                    = 8,
  87.     ftUserCancel                = 9,
  88.     ftNotSupported                = 10
  89. };
  90.  
  91. typedef OSErr FTErr;
  92.  
  93.  
  94. enum {
  95.     ftIsFTMode                    = 1 << 0,
  96.     ftNoMenus                    = 1 << 1,
  97.     ftQuiet                        = 1 << 2,
  98.     ftConfigChanged                = 1 << 4,
  99.     ftSucc                        = 1 << 7
  100. };
  101.  
  102. typedef unsigned long FTFlags;
  103.  
  104.  
  105. enum {
  106.     ftSameCircuit                = 1 << 0,
  107.     ftSendDisable                = 1 << 1,
  108.     ftReceiveDisable            = 1 << 2,
  109.     ftTextOnly                    = 1 << 3,
  110.     ftNoStdFile                    = 1 << 4,
  111.     ftMultipleFileSend            = 1 << 5
  112. };
  113.  
  114. typedef unsigned short FTAttributes;
  115.  
  116.  
  117. enum {
  118.     ftReceiving,
  119.     ftTransmitting
  120. };
  121.  
  122. typedef unsigned short FTDirection;
  123.  
  124. /*    application routines type definitions */
  125. typedef struct FTRecord FTRecord, *FTPtr, **FTHandle;
  126.  
  127. typedef pascal long (*FileTransferDefProcPtr)(TermHandle hTerm, short msg, long p1, long p2, long p3);
  128. typedef pascal OSErr (*FileTransferReadProcPtr)(unsigned long *count, Ptr pData, long refCon, short fileMsg);
  129. typedef pascal OSErr (*FileTransferWriteProcPtr)(unsigned long *count, Ptr pData, long refCon, short fileMsg);
  130. typedef pascal Size (*FileTransferSendProcPtr)(Ptr thePtr, long theSize, long refCon, CMChannel channel, CMFlags flag);
  131. typedef pascal Size (*FileTransferReceiveProcPtr)(Ptr thePtr, long theSize, long refCon, CMChannel channel, CMFlags *flag);
  132. typedef pascal OSErr (*FileTransferEnvironsProcPtr)(long refCon, ConnEnvironRec *theEnvirons);
  133. typedef pascal void (*FileTransferNotificationProcPtr)(FTHandle hFT, FSSpecPtr pFSSpec);
  134. typedef pascal void (*FileTransferChooseIdleProcPtr)(void);
  135.  
  136. #if GENERATINGCFM
  137. typedef UniversalProcPtr FileTransferDefUPP;
  138. typedef UniversalProcPtr FileTransferReadUPP;
  139. typedef UniversalProcPtr FileTransferWriteUPP;
  140. typedef UniversalProcPtr FileTransferSendUPP;
  141. typedef UniversalProcPtr FileTransferReceiveUPP;
  142. typedef UniversalProcPtr FileTransferEnvironsUPP;
  143. typedef UniversalProcPtr FileTransferNotificationUPP;
  144. typedef UniversalProcPtr FileTransferChooseIdleUPP;
  145. #else
  146. typedef FileTransferDefProcPtr FileTransferDefUPP;
  147. typedef FileTransferReadProcPtr FileTransferReadUPP;
  148. typedef FileTransferWriteProcPtr FileTransferWriteUPP;
  149. typedef FileTransferSendProcPtr FileTransferSendUPP;
  150. typedef FileTransferReceiveProcPtr FileTransferReceiveUPP;
  151. typedef FileTransferEnvironsProcPtr FileTransferEnvironsUPP;
  152. typedef FileTransferNotificationProcPtr FileTransferNotificationUPP;
  153. typedef FileTransferChooseIdleProcPtr FileTransferChooseIdleUPP;
  154. #endif
  155.  
  156. struct FTRecord {
  157.     short                            procID;
  158.     FTFlags                            flags;
  159.     FTErr                            errCode;
  160.     long                            refCon;
  161.     long                            userData;
  162.     FileTransferDefUPP                defProc;
  163.     Ptr                                config;
  164.     Ptr                                oldConfig;
  165.     FileTransferEnvironsUPP            environsProc;
  166.     long                            reserved1;
  167.     long                            reserved2;
  168.     Ptr                                ftPrivate;
  169.     FileTransferSendUPP                sendProc;
  170.     FileTransferReceiveUPP            recvProc;
  171.     FileTransferWriteUPP            writeProc;
  172.     FileTransferReadUPP                readProc;
  173.     WindowPtr                        owner;
  174.     FTDirection                        direction;
  175.     SFReply                            theReply;
  176.     long                            writePtr;
  177.     long                            readPtr;
  178.     char                            *theBuf;
  179.     long                            bufSize;
  180.     Str255                            autoRec;
  181.     FTAttributes                    attributes;
  182. };
  183.  
  184. enum {
  185. /* FTReadProc messages */
  186.     ftReadOpenFile                = 0,                            /* count = forkFlags, buffer = pblock from PBGetFInfo */
  187.     ftReadDataFork                = 1,
  188.     ftReadRsrcFork                = 2,
  189.     ftReadAbort                    = 3,
  190.     ftReadComplete                = 4,
  191.     ftReadSetFPos                = 6,                            /* count = forkFlags, buffer = pBlock same as PBSetFPos */
  192.     ftReadGetFPos                = 7,                            /* count = forkFlags, buffer = pBlock same as PBGetFPos */
  193. /* FTWriteProc messages */
  194.     ftWriteOpenFile                = 0,                            /* count = forkFlags, buffer = pblock from PBGetFInfo */
  195.     ftWriteDataFork                = 1,
  196.     ftWriteRsrcFork                = 2,
  197.     ftWriteAbort                = 3,
  198.     ftWriteComplete                = 4,
  199.     ftWriteFileInfo                = 5,
  200.     ftWriteSetFPos                = 6,                            /* count = forkFlags, buffer = pBlock same as PBSetFPos */
  201.     ftWriteGetFPos                = 7,                            /* count = forkFlags, buffer = pBlock same as PBGetFPos */
  202. /*    fork flags */
  203.     ftOpenDataFork                = 1,
  204.     ftOpenRsrcFork                = 2
  205. };
  206.  
  207. enum {
  208.     uppFileTransferDefProcInfo = kPascalStackBased
  209.          | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  210.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(TermHandle)))
  211.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
  212.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
  213.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
  214.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long))),
  215.     uppFileTransferReadProcInfo = kPascalStackBased
  216.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  217.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(unsigned long*)))
  218.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr)))
  219.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
  220.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short))),
  221.     uppFileTransferWriteProcInfo = kPascalStackBased
  222.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  223.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(unsigned long*)))
  224.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr)))
  225.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
  226.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short))),
  227.     uppFileTransferSendProcInfo = kPascalStackBased
  228.          | RESULT_SIZE(SIZE_CODE(sizeof(Size)))
  229.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(Ptr)))
  230.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
  231.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
  232.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(CMChannel)))
  233.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(CMFlags))),
  234.     uppFileTransferReceiveProcInfo = kPascalStackBased
  235.          | RESULT_SIZE(SIZE_CODE(sizeof(Size)))
  236.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(Ptr)))
  237.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
  238.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
  239.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(CMChannel)))
  240.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(CMFlags*))),
  241.     uppFileTransferEnvironsProcInfo = kPascalStackBased
  242.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  243.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long)))
  244.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(ConnEnvironRec*))),
  245.     uppFileTransferNotificationProcInfo = kPascalStackBased
  246.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(FTHandle)))
  247.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(FSSpecPtr))),
  248.     uppFileTransferChooseIdleProcInfo = kPascalStackBased
  249. };
  250.  
  251. #if GENERATINGCFM
  252. #define NewFileTransferDefProc(userRoutine)        \
  253.         (FileTransferDefUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferDefProcInfo, GetCurrentArchitecture())
  254. #define NewFileTransferReadProc(userRoutine)        \
  255.         (FileTransferReadUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferReadProcInfo, GetCurrentArchitecture())
  256. #define NewFileTransferWriteProc(userRoutine)        \
  257.         (FileTransferWriteUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferWriteProcInfo, GetCurrentArchitecture())
  258. #define NewFileTransferSendProc(userRoutine)        \
  259.         (FileTransferSendUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferSendProcInfo, GetCurrentArchitecture())
  260. #define NewFileTransferReceiveProc(userRoutine)        \
  261.         (FileTransferReceiveUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferReceiveProcInfo, GetCurrentArchitecture())
  262. #define NewFileTransferEnvironsProc(userRoutine)        \
  263.         (FileTransferEnvironsUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferEnvironsProcInfo, GetCurrentArchitecture())
  264. #define NewFileTransferNotificationProc(userRoutine)        \
  265.         (FileTransferNotificationUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferNotificationProcInfo, GetCurrentArchitecture())
  266. #define NewFileTransferChooseIdleProc(userRoutine)        \
  267.         (FileTransferChooseIdleUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferChooseIdleProcInfo, GetCurrentArchitecture())
  268. #else
  269. #define NewFileTransferDefProc(userRoutine)        \
  270.         ((FileTransferDefUPP) (userRoutine))
  271. #define NewFileTransferReadProc(userRoutine)        \
  272.         ((FileTransferReadUPP) (userRoutine))
  273. #define NewFileTransferWriteProc(userRoutine)        \
  274.         ((FileTransferWriteUPP) (userRoutine))
  275. #define NewFileTransferSendProc(userRoutine)        \
  276.         ((FileTransferSendUPP) (userRoutine))
  277. #define NewFileTransferReceiveProc(userRoutine)        \
  278.         ((FileTransferReceiveUPP) (userRoutine))
  279. #define NewFileTransferEnvironsProc(userRoutine)        \
  280.         ((FileTransferEnvironsUPP) (userRoutine))
  281. #define NewFileTransferNotificationProc(userRoutine)        \
  282.         ((FileTransferNotificationUPP) (userRoutine))
  283. #define NewFileTransferChooseIdleProc(userRoutine)        \
  284.         ((FileTransferChooseIdleUPP) (userRoutine))
  285. #endif
  286.  
  287. #if GENERATINGCFM
  288. #define CallFileTransferDefProc(userRoutine, hTerm, msg, p1, p2, p3)        \
  289.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferDefProcInfo, (hTerm), (msg), (p1), (p2), (p3))
  290. #define CallFileTransferReadProc(userRoutine, count, pData, refCon, fileMsg)        \
  291.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferReadProcInfo, (count), (pData), (refCon), (fileMsg))
  292. #define CallFileTransferWriteProc(userRoutine, count, pData, refCon, fileMsg)        \
  293.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferWriteProcInfo, (count), (pData), (refCon), (fileMsg))
  294. #define CallFileTransferSendProc(userRoutine, thePtr, theSize, refCon, channel, flag)        \
  295.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferSendProcInfo, (thePtr), (theSize), (refCon), (channel), (flag))
  296. #define CallFileTransferReceiveProc(userRoutine, thePtr, theSize, refCon, channel, flag)        \
  297.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferReceiveProcInfo, (thePtr), (theSize), (refCon), (channel), (flag))
  298. #define CallFileTransferEnvironsProc(userRoutine, refCon, theEnvirons)        \
  299.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferEnvironsProcInfo, (refCon), (theEnvirons))
  300. #define CallFileTransferNotificationProc(userRoutine, hFT, pFSSpec)        \
  301.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferNotificationProcInfo, (hFT), (pFSSpec))
  302. #define CallFileTransferChooseIdleProc(userRoutine)        \
  303.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferChooseIdleProcInfo)
  304. #else
  305. #define CallFileTransferDefProc(userRoutine, hTerm, msg, p1, p2, p3)        \
  306.         (*(userRoutine))((hTerm), (msg), (p1), (p2), (p3))
  307. #define CallFileTransferReadProc(userRoutine, count, pData, refCon, fileMsg)        \
  308.         (*(userRoutine))((count), (pData), (refCon), (fileMsg))
  309. #define CallFileTransferWriteProc(userRoutine, count, pData, refCon, fileMsg)        \
  310.         (*(userRoutine))((count), (pData), (refCon), (fileMsg))
  311. #define CallFileTransferSendProc(userRoutine, thePtr, theSize, refCon, channel, flag)        \
  312.         (*(userRoutine))((thePtr), (theSize), (refCon), (channel), (flag))
  313. #define CallFileTransferReceiveProc(userRoutine, thePtr, theSize, refCon, channel, flag)        \
  314.         (*(userRoutine))((thePtr), (theSize), (refCon), (channel), (flag))
  315. #define CallFileTransferEnvironsProc(userRoutine, refCon, theEnvirons)        \
  316.         (*(userRoutine))((refCon), (theEnvirons))
  317. #define CallFileTransferNotificationProc(userRoutine, hFT, pFSSpec)        \
  318.         (*(userRoutine))((hFT), (pFSSpec))
  319. #define CallFileTransferChooseIdleProc(userRoutine)        \
  320.         (*(userRoutine))()
  321. #endif
  322.  
  323. extern pascal FTErr InitFT(void);
  324. extern pascal Handle FTGetVersion(FTHandle hFT);
  325. extern pascal short FTGetFTVersion(void);
  326. extern pascal FTHandle FTNew(short procID, FTFlags flags, FileTransferSendUPP sendProc, FileTransferReceiveUPP recvProc, FileTransferReadUPP readProc, FileTransferWriteUPP writeProc, FileTransferEnvironsUPP environsProc, WindowPtr owner, long refCon, long userData);
  327. extern pascal void FTDispose(FTHandle hFT);
  328. extern pascal FTErr FTStart(FTHandle hFT, FTDirection direction, const SFReply *fileInfo);
  329. extern pascal FTErr FTAbort(FTHandle hFT);
  330. extern pascal FTErr FTSend(FTHandle hFT, short numFiles, FSSpecArrayPtr pFSSpec, FileTransferNotificationUPP notifyProc);
  331. extern pascal FTErr FTReceive(FTHandle hFT, FSSpecPtr pFSSpec, FileTransferNotificationUPP notifyProc);
  332. extern pascal void FTExec(FTHandle hFT);
  333. extern pascal void FTActivate(FTHandle hFT, Boolean activate);
  334. extern pascal void FTResume(FTHandle hFT, Boolean resume);
  335. extern pascal Boolean FTMenu(FTHandle hFT, short menuID, short item);
  336. extern pascal short FTChoose(FTHandle *hFT, Point where, FileTransferChooseIdleUPP idleProc);
  337. extern pascal void FTEvent(FTHandle hFT, const EventRecord *theEvent);
  338. extern pascal Boolean FTValidate(FTHandle hFT);
  339. extern pascal void FTDefault(Ptr *theConfig, short procID, Boolean allocate);
  340. extern pascal Handle FTSetupPreflight(short procID, long *magicCookie);
  341. extern pascal void FTSetupSetup(short procID, const void *theConfig, short count, DialogPtr theDialog, long *magicCookie);
  342. extern pascal Boolean FTSetupFilter(short procID, const void *theConfig, short count, DialogPtr theDialog, EventRecord *theEvent, short *theItem, long *magicCookie);
  343. extern pascal void FTSetupItem(short procID, const void *theConfig, short count, DialogPtr theDialog, short *theItem, long *magicCookie);
  344. extern pascal void FTSetupXCleanup(short procID, const void *theConfig, short count, DialogPtr theDialog, Boolean OKed, long *magicCookie);
  345. extern pascal void FTSetupPostflight(short procID);
  346. extern pascal Ptr FTGetConfig(FTHandle hFT);
  347. extern pascal short FTSetConfig(FTHandle hFT, const void *thePtr);
  348. extern pascal OSErr FTIntlToEnglish(FTHandle hFT, const void *inputPtr, Ptr *outputPtr, short language);
  349. extern pascal OSErr FTEnglishToIntl(FTHandle hFT, const void *inputPtr, Ptr *outputPtr, short language);
  350. extern pascal void FTGetToolName(short procID, Str255 name);
  351. extern pascal short FTGetProcID(ConstStr255Param name);
  352. extern pascal void FTSetRefCon(FTHandle hFT, long refCon);
  353. extern pascal long FTGetRefCon(FTHandle hFT);
  354. extern pascal void FTSetUserData(FTHandle hFT, long userData);
  355. extern pascal long FTGetUserData(FTHandle hFT);
  356. extern pascal void FTGetErrorString(FTHandle hFT, short id, Str255 errMsg);
  357.  
  358. #if PRAGMA_IMPORT_SUPPORTED
  359. #pragma import off
  360. #endif
  361.  
  362. #if PRAGMA_ALIGN_SUPPORTED
  363. #pragma options align=reset
  364. #endif
  365.  
  366. #ifdef __cplusplus
  367. }
  368. #endif
  369.  
  370. #endif /* __FILETRANSFERS__ */
  371.